﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows.Forms;
using System.Xml.Serialization;

using FCNS.KeepMoney.Util;

namespace FCNS.KeepMoney.Configuration
{
    public class AceApplication
    {
        bool encryption = true;
        public bool EncryptionData
        {
            get { return encryption; }
            set { encryption = value; }
        }

        bool firstDayIsSunday = false;
        public bool FirstDayIsSunday
        {
            get { return firstDayIsSunday; }
            set { firstDayIsSunday = value; }
        }

        /// <summary>
        /// 获取或设置日期的显示格式
        /// </summary>
        public string DateFormat
        {
            get { return KeepMoneyLibrary.LibDefines.dataTimeFormat; }
            set { KeepMoneyLibrary.LibDefines.dataTimeFormat = value; }
        }

        string lang = AppDefines.defaultLanguage;
        /// <summary>
        /// 获取或设置用户假面语言
        /// </summary>
        public string Language
        {
            get { return lang; }
            set { lang = value; }
        }

        string urlName = string.Empty;
        /// <summary>
        /// keepmoney.org 用户名
        /// </summary>
        public string UrlName
        {
            get { return urlName; }
            set { urlName = value; }
        }

        string urlPwd = string.Empty;
        /// <summary>
        /// keepmoney.org 密码
        /// </summary>
        public string UrlPwd
        {
            get { return urlPwd; }
            set { urlPwd = value; }
        }

        bool displayTheForm = true;
        /// <summary>
        /// 获取或设置是否显示操作提示窗体
        /// </summary>
        public bool DisplayThePromptForm
        {
            get
            {
                return displayTheForm;
            }
            set { displayTheForm = value; }
        }

        bool displayTheLoginForm = true;
        /// <summary>
        /// 获取或设置是否显示登录窗体
        /// </summary>
        public bool DisplayTheLoginForm
        {
            get { return displayTheLoginForm; }
            set { displayTheLoginForm = value; }
        }

        bool enableAlertMessage = true;
        /// <summary>
        /// 获取或设置是否启用消息提示
        /// </summary>
        public bool EnablAlertMessage
        {
            get { return enableAlertMessage; }
            set { enableAlertMessage = value; }
        }

        bool autoRun = false;
        /// <summary>
        /// 获取或设置是否随系统启动
        /// </summary>
        public bool AutoRun
        {
            get { return autoRun; }
            set { autoRun = value; }
        }

        bool autoOpen = true;
        public bool AutoOpenKMD
        {
            get { return autoOpen; }
            set { autoOpen = value; }
        }

        ulong hotkey1 = (ulong)(Keys.Control | Keys.Alt | Keys.N);
        /// <summary>
        /// 获取或设置快速添加账务记录的热键
        /// </summary>
        public ulong HotkeyEntry
        {
            get { return hotkey1; }
            set { hotkey1 = value; }
        }

        ulong hotkey2 = (ulong)(Keys.Control | Keys.Alt | Keys.F);
        /// <summary>
        /// 获取或设置显示主窗体的热键
        /// </summary>
        public ulong HotkeyForm
        {
            get { return hotkey2; }
            set { hotkey2 = value; }
        }

        bool showOverdueData = false;
        /// <summary>
        /// 获取或设置是否显示已过期的数据
        /// </summary>
        public bool ShowOverdueData
        {
            get { return showOverdueData; }
            set { showOverdueData = value; }
        }

        private List<AceFileOpenRecord> fileOpenRecord = new List<AceFileOpenRecord>();
        /// <summary>
        /// 获取或设置曾经打开过的数据库路径列表
        /// </summary>
        [XmlArrayItem("FileOpenRecord")]
        public List<AceFileOpenRecord> FileOpenRecords
        {
            get { return fileOpenRecord; }
            set { fileOpenRecord = value; }
        }
    }

    [XmlType(TypeName = "Record")]
    public sealed class AceFileOpenRecord
    {
        int id = 0;
        /// <summary>
        /// 记录最后选择的账务群组
        /// </summary>
        public int LastSelectedGroupId
        {
            get { return id; }
            set { id = value; }
        }

        string filePath = string.Empty;
        public string FilePath
        {
            get { return filePath; }
            set { filePath = value; }
        }
    }
}